<?php
class search extends CWidget
{
    public function init()
    {
        parent::init();
    }
    public function run()
    {
    	$uri= Yii::app()->request->requestUri;
    	echo CHtml::beginForm(CHtml::normalizeUrl(array('search/index')), 'get', array('id'=>'filter-form'))
		    . CHtml::textField('string', (isset($_GET['string'])) ? $_GET['string'] : '', array('id'=>'string'))
		    . CHtml::submitButton('Tìm kiếm', array('name'=>'','id'=>'btn'))
		    . CHtml::endForm();
		    Yii::app()->clientScript->registerScript('search',
			    "var ajaxUpdateTimeout;
			    var ajaxRequest;
			    $('input#string').keyup(function(){
			        ajaxRequest = $(this).serialize();
			        clearTimeout(ajaxUpdateTimeout);
			        ajaxUpdateTimeout = setTimeout(function () {
			            $.fn.yiiListView.update(
							// this is the id of the CListView
			                'ajaxListView',
			                {data: ajaxRequest}
			            )
			            $.fn.yiiListView.update(
						// this is the id of the CListView
			                'ajaxListView1',
			                {data: ajaxRequest}
			            )
			        },
			        300);
			    });"
			);
    }
    
}
?>